import {defineStore} from "pinia";
import {ref} from "vue";
import {setBadge} from "@/utils/pushUtil";

export const useBadgeStore = defineStore('badge', () => {
        const badge = ref()
        const clearBadge = () => {
            badge.value = 0
            setBadge(0)
        }
        return {
            badge,
            clearBadge
        }
    },
    {
        persist: {
            storage: {
                setItem(key, value) {
                    uni.setStorageSync(key, value)
                },
                getItem(key) {
                    return uni.getStorageSync(key)
                },
            },
        },
    }
)